#ifndef _PROTOCOL_H_
#define _PROTOCOL_H_

#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/select.h>

#define MAX_MSG_LEN 255
#define SERVER_ID 0
 
#define ACK     0
#define NACK    1
#define MSG     2
#define CLOSE   3

typedef struct {
    unsigned short int  id;
    char        type;
    char        ack_mode;
	unsigned short int	tam_msg;
    char 		orig_id[16];
    char		dest_id[16];
} Header;

void initialize_header (Header* hdr, unsigned short int message_id, char ack_mode, char type, char* orig_id, char* dest_id);

int encapsula(char** block, char* msg, Header* hdr);

void desencapsula(char* block, char** msg, Header* hdr);

#endif /* _PROTOCOL_H_ */
